package com.hualan.servlet;

import com.alibaba.fastjson.JSON;
import com.hualan.bean.PanghuShopGoods;
import com.hualan.dao.SelectShop;
import com.hualan.dao.impl.SelectShopImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/goods/select")
public class ShopGoodsSelectServlet extends HttpServlet {
    private static SelectShop selectShop = new SelectShopImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        String name = req.getParameter("name");
        int page = Integer.parseInt(req.getParameter("page"));
        int size = Integer.parseInt(req.getParameter("size"));
        List<PanghuShopGoods> p = selectShop.selectShop(name, page, size);
        resp.getWriter().write(JSON.toJSONString(p));
    }
}
